#ifndef _DICOM_HTTP_HANDLER__H_
#define _DICOM_HTTP_HANDLER__H_

#include <map>
#include <gwbase/base/conf.h>
#include <onion/onion.h>
#include <onion/request.h>
#include <onion/response.h>
#include "dicom/restful_url.h"
#include "dicom/ref_object.h"

namespace dicom {

class Gateway;

class HttpHandler : public RefObject {
 public:
  HttpHandler(onion_request* req) : req_(req), state_(st_processing) {}
  virtual ~HttpHandler() {}

  // called after recved full request
  virtual int HandleRequest(onion_request* req, onion_response* resp) = 0;

  // this called when connetion is closed
  virtual void Cleanup() {}

  virtual const char* GetName() const = 0;

  void SetUrlParams(const UrlParams& params);

 protected:
  enum State {
    st_recving_req,
    st_processing,
    st_done,
    st_error,
  };

  onion_request* req_;
  UrlParams params_;
  State state_;
};
}

#endif  // _DICOM_HTTP_HANDLER__H_
